package com.lyfei.yd.admin.web;

import com.lyfei.yd.admin.security.model.LoginBody;
import com.lyfei.yd.admin.security.service.SysLoginService;
import com.lyfei.yd.common.constant.Constants;
import com.lyfei.yd.common.core.domain.AjaxResult;
import com.lyfei.yd.system.domain.entity.Category;
import com.lyfei.yd.system.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @Autowired
    private SysLoginService loginService;

    @Autowired
    private CategoryService categoryService;

    @GetMapping("/test")
    public String test() {
        categoryService.removeById(6L);
        return "test";
    }

    @GetMapping("/ates")
    public String test1() {
        return "ates";
    }

    @PostMapping("/tes login")
    public AjaxResult Login(@RequestBody LoginBody loginBody) {
        AjaxResult ajax = AjaxResult.success();

        String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(), loginBody.getUuid(), false);
        ajax.put(Constants.TOKEN, token);

        return ajax;
    }

}
